package study.stream.并行流;

import cn.hutool.json.JSON;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONString;
import org.springframework.beans.BeanUtils;
import study.User;
import study.UserTest;
import study.Utils;
import sun.security.ssl.SunJSSE;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @Author 刘伟涛
 * @Date 2023/12/19 10:09
 **/
public class Demo1 {
    public static void main(String[] args) {
        List<User> userList = Utils.getAnyUserList(1000);
        boolean flag = true;
        for (int g = 0; g < 100; g++) {
            List<UserTest> collect = userList.parallelStream().map(user -> {
                UserTest userTest = new UserTest();
                BeanUtils.copyProperties(user, userTest);
                return userTest;
            }).collect(Collectors.toList());
            int position = 0;
            for (int i = 0; i < collect.size(); i++) {
                if(!collect.get(i).getId().equals(i + 1)){
                    flag = false;
                    position = i;
                }
            }
            System.out.println(collect);
            System.out.println(position);
        }
        System.out.println(flag);
        System.out.println();
    }
}
